{% extends 'dashboard/base.html' %}
{% load i18n %}
{% load materializecss %}

{% block title %}
  {% if site.pk %}
    {{ site }}
  {% else %}
    {% trans "Add new site settings" context "Site settings page title" %}
  {% endif %}
   - {% trans "Site settings" context "Dashboard site settings" %} - {{ block.super }}
{% endblock %}

{% block body_class %}body-settings{% endblock %}

{% block menu_settings_class %}active{% endblock %}

{% block breadcrumbs %}
  <ul class="breadcrumbs breadcrumbs--history">
    <li class="visible-s">
      {% trans "Site settings" context "Dashboard site settings" %}
    </li>
  </ul>
{% endblock %}

{% block content %}
  <div class="row">
    <div class="col m12 l9">
      <div class="card">
        <form method="post" id="form-category" enctype="multipart/form-data" novalidate>
          <div class="card-content card-content-form">
            {% csrf_token %}
            <div class="row">
              {{ form.name|materializecss }}
            </div>
            <div class="row">
              {{ form.domain|materializecss }}
            </div>
            <div class="row">
              {{ form.header_text|materializecss }}
            </div>
            <div class="row">
              {{ form.description|materializecss }}
            </div>

            <h5 class="card-title">{% trans "Authorization keys" context "Authorization keys formset title" %}</h5>
              {{ formset.management_form }}
              {{ formset.non_form_errors.as_ul }}
          </div>

          <div class="formset-table-container">
            <table id="formset" class="formset-table">
              {% for form in formset.forms %}
                {% if forloop.first %}
                  <thead>
                  <tr>
                    {% for field in form.visible_fields %}
                      <th>{{ field.label|capfirst }}</th>
                    {% endfor %}
                  </tr>
                  </thead>
                {% endif %}
                <tr>
                  {% for field in form.visible_fields %}
                    <td{% if forloop.last %} class="center-align"{% endif %}>
                      {% if forloop.first %}
                        {% for hidden in form.hidden_fields %}
                          {{ hidden }}
                        {% endfor %}
                      {% endif %}
                      {{ field|materializecss }}
                    </td>
                  {% endfor %}
                </tr>
              {% endfor %}
            </table>
          </div>
          <div class="card-action right-align">
            <a class="btn btn-flat" href="{% url "dashboard:index" %}" traget="_blank">
              {% trans "Cancel" context "Dashboard cancel action" %}
            </a>
            <button type="submit" class="btn waves-effect waves-light">
              {% trans "Update" context "Dashboard update action" %}
            </button>
          </div>
        </form>
      </div>
    </div>
    <div class="col m12 l3 help-box"></div>
  </div>
{% endblock %}
